package com.hg.design.behavior.visitor.biancheng.ex3;

public class VisitorPattern {
    public static void main(String[] args) {
        ObjectStructure os = new ObjectStructure();
        Element leaf1 = new LeafElement("✌1");
        Element leaf2 = new LeafElement("✌2");
        CompositeElement composite = new CompositeElement();
        composite.add(leaf1);
        composite.add(leaf2);

        os.add(leaf1);
        os.add(leaf2);
        os.add(composite);
        Visitor visitor = new ConcreteVisitorA();
        os.accept(visitor);
        System.out.println("------------------------");
        visitor = new ConcreteVisitorB();
        os.accept(visitor);
    }
}
